
package controler;

/**
 *
 * @author Asia
 */
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ExceptionLogger { 

  static private FileHandler XMLfile;
 // static private Formatter XMLFormatter;

  /**
   * tworzy log w pliku data.xml
   * @throws IOException 
   */
  //TODO: czy to trzeba nadpisać dla appletu czy zadziała samo?
  static public void setup() throws IOException {

    SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss-SSS");
    Date resultdate = new Date();
    String time=date_format.format(resultdate);
      File f = new File("logs");
    if (!f.exists()){
        f.mkdir();
    }
    String filename="logs/"+time+".xml";
    Logger logger = Logger.getLogger("");
    logger.setLevel(Level.INFO);
    XMLfile = new FileHandler(filename, true);
    logger.addHandler(XMLfile);
  }
} 
